package com.czk.doc;

import com.czk.util.ClientUtil;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 *
 * @Author:ChenZhangKun
 * @Date: 2021/6/13 23:28
 */
public class DeleteDoc {
    public static void main(String[] args) throws IOException {
        // 拿到客户端
        RestHighLevelClient highLevelClient = ClientUtil.getHighLevelClient();
        // 创建删除请求
        DeleteRequest deleteRequest = new DeleteRequest();
        // 创建文档
        deleteRequest.index("user").id("1001");
        // 删除
        DeleteResponse response = highLevelClient.delete(deleteRequest, RequestOptions.DEFAULT);
        System.out.println(response.toString());
        highLevelClient.close();
    }
}
